package com.resou.reader.bookshelf.readhistory.datasupport;

import android.os.Parcel;
import android.os.Parcelable;

import org.litepal.crud.LitePalSupport;

/**
 * 用户每打开书本，添加书本到书架
 */
public class BookCollection extends LitePalSupport implements Parcelable {
    private String bookId;  //书本id
    private String name;    //书名
    private String author; //作者
    private String picUrl; //书本图片
    private String description; //描述
    private long createTime; //创建时间
    private long updateTime;//更新时间
    private String parentCategoryName;//父分类名称
    private String keywords;//关键词
    private String categoryName;//分类名称
    private float totalWord; //总字数
    private int serialStatus;//连载状态
    private String shareUrl;//分享链接
    private int chapterSum;//章节总数

    //添加字段+++++++++++++
    private String historyChapterId = "-1";//观看历史章节ID
    private String historyChapterName;//观看历史章节名称
    private int chapterIndex;//观看历史章节在总章节中的索引
    private int pageIndex;//页码
    private int charIndex;//字符在本章节中的索引
    private long userUpdateTime;//记录用户用户上次观看退出的时间
    private int isResfresh = 0; //0表示默认，1表示 阅读器返回 刷新第一项数据，2表示进入阅读器 更换列表顺序；
    //书本同步的字段
    private String readStatus; //阅读状态
    private int whetherUpdate; //是否更新
    private Integer freeStatus;     //免费状态 0免费 1不显示 ，3会员免费
    //追书id
    private String zsBookId;
    private String lastChapterName;

    public String getLastChapterName() {
        return lastChapterName;
    }

    public void setLastChapterName(String lastChapterName) {
        this.lastChapterName = lastChapterName;
    }

    public String getZsBookId() {
        return zsBookId;
    }

    public void setZsBookId(String zsBookId) {
        this.zsBookId = zsBookId;
    }

    public int getFreeStatus() {
        return freeStatus == null ? 0 : freeStatus;
    }

    public void setFreeStatus(int freeStatus) {
        this.freeStatus = freeStatus;
    }

    public String getShareUrl() {
        return shareUrl;
    }

    public void setShareUrl(String shareUrl) {
        this.shareUrl = shareUrl;
    }

    public String getHistoryChapterName() {
        return historyChapterName;
    }

    public void setHistoryChapterName(String historyChapterName) {
        this.historyChapterName = historyChapterName;
    }

    public void setChapterSum(int chapterSum) {
        this.chapterSum = chapterSum;
    }

    public int getChapterSum() {
        return chapterSum;
    }

    public int getSerialStatus() {
        return serialStatus;
    }

    public void setSerialStatus(int serialStatus) {
        this.serialStatus = serialStatus;
    }

    public float getTotalWord() {
        return totalWord;
    }

    public void setTotalWord(float totalWord) {
        this.totalWord = totalWord;
    }

    public String getHistoryChapterId() {
        return historyChapterId;
    }

    public void setHistoryChapterId(String historyChapterId) {
        this.historyChapterId = historyChapterId;
    }

    public int getChapterIndex() {
        return chapterIndex;
    }

    public void setChapterIndex(int chapterIndex) {
        this.chapterIndex = chapterIndex;
    }

    public int getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
    }

    public int getCharIndex() {
        return charIndex;
    }

    public void setCharIndex(int charIndex) {
        this.charIndex = charIndex;
    }

    public long getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(long updateTime) {
        this.updateTime = updateTime;
    }

    public String getParentCategoryName() {
        return parentCategoryName;
    }

    public void setParentCategoryName(String parentCategoryName) {
        this.parentCategoryName = parentCategoryName;
    }

    public int isRemove() {
        return isResfresh;
    }

    public void setRemove(int remove) {
        isResfresh = remove;
    }

    public String getKeywords() {
        return keywords;
    }

    public void setKeywords(String keywords) {
        this.keywords = keywords;
    }

    public String getCategoryName() {
        return categoryName;
    }

    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }

    public long getUserUpdateTime() {
        return userUpdateTime;
    }

    public void setUserUpdateTime(long userUpdateTime) {
        this.userUpdateTime = userUpdateTime;
    }

    public String getBookId() {
        return bookId == null ? "" : bookId;
    }

    public void setBookId(String bookId) {
        this.bookId = bookId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getPicUrl() {
        return picUrl;
    }

    public void setPicUrl(String picUrl) {
        this.picUrl = picUrl;
    }

    public long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(long createTime) {
        this.createTime = createTime;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public BookCollection() {
    }

    public String getReadStatus() {
        return this.readStatus;
    }

    public void setReadStatus(String readStatus) {
        this.readStatus = readStatus;
    }

    public int getWhetherUpdate() {
        return this.whetherUpdate;
    }

    public void setWhetherUpdate(int whetherUpdate) {
        this.whetherUpdate = whetherUpdate;
    }

    @Override
    public String toString() {
        return "BookCollection{" +
                "bookId='" + bookId + '\'' +
                ", name='" + name + '\'' +
                ", author='" + author + '\'' +
                ", picUrl='" + picUrl + '\'' +
                ", description='" + description + '\'' +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                ", parentCategoryName='" + parentCategoryName + '\'' +
                ", keywords='" + keywords + '\'' +
                ", categoryName='" + categoryName + '\'' +
                ", totalWord=" + totalWord +
                ", serialStatus=" + serialStatus +
                ", shareUrl='" + shareUrl + '\'' +
                ", chapterSum=" + chapterSum +
                ", historyChapterId='" + historyChapterId + '\'' +
                ", historyChapterName='" + historyChapterName + '\'' +
                ", chapterIndex=" + chapterIndex +
                ", pageIndex=" + pageIndex +
                ", charIndex=" + charIndex +
                ", userUpdateTime=" + userUpdateTime +
                ", readStatus='" + readStatus + '\'' +
                ", whetherUpdate=" + whetherUpdate +
                ", freeStatus=" + freeStatus +
                ", zsBookId='" + zsBookId + '\'' +
                ", lastChapterName='" + lastChapterName + '\'' +
                '}';
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.bookId);
        dest.writeString(this.name);
        dest.writeString(this.author);
        dest.writeString(this.picUrl);
        dest.writeString(this.description);
        dest.writeLong(this.createTime);
        dest.writeLong(this.updateTime);
        dest.writeString(this.parentCategoryName);
        dest.writeString(this.keywords);
        dest.writeString(this.categoryName);
        dest.writeFloat(this.totalWord);
        dest.writeInt(this.serialStatus);
        dest.writeString(this.shareUrl);
        dest.writeInt(this.chapterSum);
        dest.writeString(this.historyChapterId);
        dest.writeString(this.historyChapterName);
        dest.writeInt(this.chapterIndex);
        dest.writeInt(this.pageIndex);
        dest.writeInt(this.charIndex);
        dest.writeLong(this.userUpdateTime);
        dest.writeString(this.readStatus);
        dest.writeInt(this.whetherUpdate);
//        dest.writeInt(this.freeStatus == null ? 0 : this.freeStatus);
        dest.writeString(this.zsBookId);
        dest.writeString(this.lastChapterName);
    }

    protected BookCollection(Parcel in) {
        this.bookId = in.readString();
        this.name = in.readString();
        this.author = in.readString();
        this.picUrl = in.readString();
        this.description = in.readString();
        this.createTime = in.readLong();
        this.updateTime = in.readLong();
        this.parentCategoryName = in.readString();
        this.keywords = in.readString();
        this.categoryName = in.readString();
        this.totalWord = in.readFloat();
        this.serialStatus = in.readInt();
        this.shareUrl = in.readString();
        this.chapterSum = in.readInt();
        this.historyChapterId = in.readString();
        this.historyChapterName = in.readString();
        this.chapterIndex = in.readInt();
        this.pageIndex = in.readInt();
        this.charIndex = in.readInt();
        this.userUpdateTime = in.readLong();
        this.readStatus = in.readString();
        this.whetherUpdate = in.readInt();
//        this.freeStatus = in.readInt();
        this.zsBookId = in.readString();
        this.lastChapterName = in.readString();
    }

    public static final Creator<BookCollection> CREATOR = new Creator<BookCollection>() {
        @Override
        public BookCollection createFromParcel(Parcel source) {
            return new BookCollection(source);
        }

        @Override
        public BookCollection[] newArray(int size) {
            return new BookCollection[size];
        }
    };
}
